
%Declare the symbolic variables (syms)
syms shksVal uzeroVal omegabarVal OmegabVal OmegagVal lb0Val


f=  k/psi/phi0*exp(-omegabarVal)-...
    uzeroVal/(uzeroVal+shksVal*(1-uzeroVal))...
    * (xib*Omegab*exp(OmegabVal)+xig*Omegag*exp(OmegagVal)) ...
    -shksVal*xig*lb0Val/(uzeroVal+shksVal*(1-uzeroVal))*(Omegag*exp(OmegagVal)-Omegab*exp(OmegabVal)); 


%Take symbolic derivatives
dd1 = diff(f,shksVal);
dd2 = diff(f,uzeroVal);
dd3 = diff(f,omegabarVal);
dd4 = diff(f,OmegabVal);
dd5 = diff(f,OmegagVal);
dd6 = diff(f,lb0Val);

%Evaluates symbolic derivatives

shksVal=s;        %linearize
uzeroVal=U0star;  %linearize
omegabarVal=0;    %loglin
OmegabVal=0;      %loglin
OmegagVal=0;      %loglin
lb0Val=lb0;       %linearize

D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
D5=subs(dd5);
D6=subs(dd6);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
d5=double(D5);
d6=double(D6);

ACont(1,shksLog)      = -d1;
ACont(1,uzeroLog)     = -d2;
ACont(1,omegabarLog)  = -d3;
ACont(1,OmegabLog)    = -d4;
ACont(1,OmegagLog)    = -d5;
ACont(1,lb0Log)       = -d6;  
%ALag(1,lb0Log)        =  d6;  %lagged as lb0og is the t+1 variable

